package com.zmn.oms.services.impl.refund;

import com.zmn.common.utils.date.DateUtil;
import com.zmn.oms.model.entity.refund.OrderWorkRefund;
import com.zmn.oms.persistence.interfaces.refund.OrderWorkRefundDao;
import com.zmn.oms.services.interfaces.refund.OrderWorkRefundService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类描述：工单退款记录
 *
 * @author lujia
 * @date 2018/12/18 21:09
 */
@Service
public class OrderWorkRefundServiceImpl implements OrderWorkRefundService {

	@Resource
	OrderWorkRefundDao orderWorkRefundDao;

	@Override
	public List<OrderWorkRefund> findOrderWorkRefundByOrderIdAndWorkId(Long orderId, Long workId) {
		return orderWorkRefundDao.findOrderWorkRefundByOrderIdAndWorkId(orderId, workId);
	}

	@Override
	public int insertOrderWorkRefund(OrderWorkRefund orderWorkRefund) {
		return orderWorkRefundDao.insertOrderWorkRefund(orderWorkRefund);
	}

	@Override
	public int insertOrderWorkRefund(Long orderId, Long workId, Integer amount, Integer amountType,Integer type) {
		OrderWorkRefund orderWorkRefund = new OrderWorkRefund();
		orderWorkRefund.setOrderId(orderId);
		orderWorkRefund.setWorkId(workId);
		orderWorkRefund.setAmount(amount);
		orderWorkRefund.setAmountType(amountType);
		orderWorkRefund.setType(type);
		return orderWorkRefundDao.insertOrderWorkRefund(orderWorkRefund);
	}

	@Override
	public int insertOrderWorkRefund(Long orderId, Long workId, Integer amount, Integer amountType, Integer type, Integer payChannelId) {
		OrderWorkRefund orderWorkRefund = new OrderWorkRefund();
		orderWorkRefund.setOrderId(orderId);
		orderWorkRefund.setWorkId(workId);
		orderWorkRefund.setAmount(amount);
		orderWorkRefund.setAmountType(amountType);
		orderWorkRefund.setType(type);
		orderWorkRefund.setPayChannelId(payChannelId);
		return orderWorkRefundDao.insertOrderWorkRefund(orderWorkRefund);
	}

	@Override
	public int updateByRefundId(OrderWorkRefund orderWorkRefund) {
		orderWorkRefund.setUpdaterTime(DateUtil.getNow());
		return orderWorkRefundDao.updateByRefundId(orderWorkRefund);
	}

	@Override
	public int deleteOrderWorkRefund(Long orderId, Long refundId) {
		return orderWorkRefundDao.deleteOrderWorkRefund(orderId, refundId);
	}
}
